import 'package:flutter/material.dart';
import 'package:personinfo/utils/ColorUtil.dart';

class messgeNav extends StatelessWidget{
  String title;  //标题
  String tipNum; //角标数量
  final GestureTapCallback? onTap;
  messgeNav({super.key, required this.title, required this.tipNum, this.onTap});

  //是否展示角标
  Widget _showBadge(){
    if((tipNum=='') ){
      return const SizedBox();
    } else {
      return  Container(
        padding: const EdgeInsets.fromLTRB(10, 2, 10, 2),
        decoration: const BoxDecoration(borderRadius: BorderRadius.all(Radius.circular(8)),color: ColorUtil.primaryBadgeBgColor),
        child: Text(tipNum!,style: const TextStyle(color: Colors.white,fontSize: 12),),
      ) ;
    }
  }


  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return
      GestureDetector(
        behavior: HitTestBehavior.translucent,
        onTap: onTap,
        child: Padding(
        padding: const EdgeInsets.fromLTRB(16, 8, 16, 8),
        child:Flex(
          direction: Axis.horizontal,
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            Text(title,style: TextStyle(fontSize: 14,color: Colors.black),),
            Row(
              children: [
                _showBadge(),
                const Icon(Icons.arrow_right)
              ],
            )
          ],
        )
      )
    );
  }

}

